package com.voltmao.webpro.utils.wechat.core;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by zhouyang on 2017/1/6.
 */
public class JsApiTicket {

    private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger(JsApiTicket.class.getName());


    public int getErrcode() {
        return errcode;
    }

    public void setErrcode(int errcode) {
        this.errcode = errcode;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public String getTicket() {
        return ticket;
    }

    public void setTicket(String ticket) {
        this.ticket = ticket;
    }

    public long getExpires_in() {
        return expires_in;
    }

    public void setExpires_in(long expires_in) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.MINUTE, 1);
        this.expires_in = cal.getTime().getTime();
    }

    private String access_token;       // 接口访问凭证


    /**
     * 验证是否过期
     *
     * @return
     */
    public boolean isValid() {

        logger.info("jstoken isValid  ===> expires_in:" + this.expires_in + "    currentTm:" + System.currentTimeMillis());


        return this.expires_in < System.currentTimeMillis();
    }

    private int errcode;
    private String errmsg;
    private String ticket;
    private long expires_in;
}
